import request from '@/utils/request'

export function getSubject() {
  return request({
    url: '/p/pms/subject/listAll',
    method: 'get'
  })
}

export function addSubject(name) {
  return request({
    url: '/pms/subject/create',
    method: 'post',
    data: {
      name: name,
      sort: 0
    }
  })
}

export function getCategories(id) {
  return request({
    url: '/p/pms/bookCategory/sub/' + id,
    method: 'get',

  })
}

export function fetchList(params) {
  return request({
    url: '/p/pms/bookCategory/list',
    method: 'get',
    params: params
  })
}

export function deleteProductCate(id) {
  return request({
    url: '/pms/bookCategory/delete/' + id,
    method: 'get'
  })
}

export function getTopCategory() {
  return request({
    url: '/p/pms/bookCategory/getTopCate',
    method: 'get'
  })
}

export function createProductCate(data) {
  return request({
    url: '/pms/bookCategory/create',
    method: 'post',
    data: data
  })
}

export function updateProductCate(id, data) {
  return request({
    url: '/pms/bookCategory/update/' + id,
    method: 'post',
    data: data
  })
}

export function getProductCate(id) {
  return request({
    url: '/productCategory/' + id,
    method: 'get',
  })
}

export function updateShowStatus(data) {
  return request({
    url: '/productCategory/update/showStatus',
    method: 'post',
    data: data
  })
}

export function updateNavStatus(data) {
  return request({
    url: '/productCategory/update/navStatus',
    method: 'post',
    data: data
  })
}

export function fetchListWithChildren() {
  return request({
    url: '/productCategory/list/withChildren',
    method: 'get'
  })
}

export function updateHidden(id, hidden) {
  return request({
    url: '/pms/bookCategory/hidden/' + id,
    method: 'get',
    params: {
      hidden
    }
  })
}

export function getCategoryTree() {
  return request({
    url: '/p/pms/bookCategory/listTree',
    method: 'get'
  })
}


